# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-hgapi
pkgname=('python2-hgapi' 'python-hgapi')
_pkgname=hgapi
pkgver=1.7.4
pkgrel=9
pkgdesc='A pure-Python API to Mercurial, that uses the command-line interface instead of the internal Mercurial API.'
arch=('any')
url='https://bitbucket.org/haard/hgapi/'
license=('MIT')
makedepends=('python2-setuptools' 'python-setuptools' 'mercurial')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('302974c1c7e4197e937b8668695ac102d000279da20540ee712ccdc98264e91d6bb0661f517c471e6cc88a844dc154fe141fc344d861fa63a20e8d88a47defa1')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-hgapi() {
  depends=('python2')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 \
    --skip-build
}

package_python-hgapi() {
  depends=('python')

  cd "$_pkgname-$pkgver"

  python setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 \
    --skip-build
}

